package com.cbtx.module_sp.ui.activity

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.bumptech.glide.Glide
import com.cbtx.module.common.bean.GoodsEntity
import com.cbtx.module.common.vm.RenZhengDetailVM
import com.cbtx.module_sp.MyApplication
import com.cbtx.module_sp.R
import com.cbtx.module_sp.ui.activity.base.MyBaseVMActivity
import kotlinx.android.synthetic.main.sp_activity_renzheng_detail.*

class RenZhengDetailActivity: MyBaseVMActivity<RenZhengDetailVM>() {

    companion object{
        fun start(activity: Activity , renZhengItem: GoodsEntity.DataBean.ListBean?){
            val intent = Intent(activity,RenZhengDetailActivity::class.java)
            intent.putExtra("renZhengItem",renZhengItem)
            activity.startActivity(intent)
        }
    }
    override fun getPresenterClazz(): Class<RenZhengDetailVM> {
         return RenZhengDetailVM::class.java
    }

    override fun getLayoutId(): Int {

        return R.layout.sp_activity_renzheng_detail
    }

    override fun initView(savedInstanceState: Bundle?) {

        mTvCode.text = "云屏编码${MyApplication.mAndroidId}"

        mVM.getIntent(intent)
        addClickListener(mTvBack)

        Glide.with(mActivity!!)
            .load(mVM.renZhengItem?.coverImg)
            .error(R.drawable.ic_default_small)
            .placeholder(R.drawable.ic_default_small)
            .into(mIvCover)

        mTvTitle.text = mVM.renZhengItem?.goodsName
        mTvType.text = mVM.renZhengItem?.category
//        mTvDistrict.text = mVM.renZhengItem?.addressname
        mTvPrice.text = mVM.mPriceStr
        mTvTime.text = mVM.renZhengItem?.years

        mIvQRCode.setImageBitmap(mVM.getQrBitmap())
    }

    override fun onMyViewClick(view: View) {

        if (view.id == R.id.mTvBack){
            finish()
        }
    }

    override fun getData() {

    }

}